package 剑指offer;

import java.util.Stack;

/**
 * @author zhangjunfei
 * @date 2023/8/30 16:07
 */
public class O_30 {

    Stack<Integer> stack = new Stack<>();
    Stack<Integer> stackB = new Stack<>();

    public void push(int x) {
        stack.push(x);
        if (stackB.isEmpty() || x <= stackB.peek()) {
            stackB.push(x);
        }
    }

    public void pop() {
        if (stack.pop().equals(stackB.peek())) {
            stackB.pop();
        }
    }

    public int top() {
       return stack.peek();
    }

    public int min(){
       return stackB.peek();

    }
}
